package com.ada.spark.savemode

import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession

object SaveModeTest {
    def main(args: Array[String]): Unit = {
        //创建配置对象
        val conf: SparkConf = new SparkConf().setAppName("ParquetTest").setMaster("local[*]")

        //创建SparkSql的环境对象
        val spark: SparkSession = SparkSession.builder().config(conf).getOrCreate();

        val peopleDF = spark.read.format("json").load("format/people.json")

        /*
          SaveMode分类：
          "error"(default)   如果文件存在，则报错
          "append"           追加
          "overwrite"        覆写
          "ignore"           数据存在，则忽略
         */
        peopleDF.write.format("csv").mode("overwrite").save("format/people")

        peopleDF.show()
    }
}
